from scrapy_redis.spiders import RedisSpider
from redis_jd.items import RedisJdItem

class GoSpider(RedisSpider):
    name = 'go'
    allowed_domains = ['kaishi.com']
    #start_urls = ['https://search.jd.com/Search?keyword=%E6%89%8B%E6%9C%BA&enc=utf-8&pvid=40ebbc9007f74af79c9e06cb265ca537']
    redis_key = 'gospider:start_urls'

    def parse(self, response):
        jd = RedisJdItem()
        name = response.xpath('//ul/li/div/div[4]/a/em/text()[1]').getall()
        jg = response.xpath('//ul/li/div/div[3]/strong/i/text()').getall()
        for i,x in zip(name,jg):
            jd['name'] = i
            jd['jg'] = x
            jd['url']=response.url
            yield jd


